<template>
  <el-card class="box-card" style="width: 1180px">
    <!--表格-->
    <el-table :data="logList" stripe style="width: 100%">
      <el-table-column prop="srOperator" label="管理员" width="180">
      </el-table-column>
      <el-table-column prop="srOperateTime" label="操作时间" width="180">
      </el-table-column>
      <el-table-column prop="srClassName" label="操作模块"> </el-table-column>
      <el-table-column prop="srMethodName" label="操作方法"> </el-table-column>
      <el-table-column label="操作">
        <template slot-scope="scope">
          <el-popconfirm
            title="这是一段内容确定删除吗？"
            @confirm="handleDelete(scope.row.srId)"
          >
            <el-button size="mini" slot="reference" type="danger"
              >删除</el-button
            >
          </el-popconfirm>
        </template>
      </el-table-column>
    </el-table>
    <el-pagination
      @size-change="handleSizeChange"
      @current-change="handleCurrentChange"
      :current-page="query.pageIndex"
      :page-sizes="pageInfo.pageSizes"
      :page-size="query.pageSize"
      layout="total, sizes, prev, pager, next, jumper"
      :total="pageInfo.total"
    >
    </el-pagination>
  </el-card>
</template>

<script>
export default {
  name: "Admin",
  data() {
    return {
      logList: [],
      pageInfo: {
        pageSizes: [5, 10, 20, 50],
         total: "",
        pages:"",
      },
      //封装的请求参数
      query: {
        pageIndex: 1,
        pageSize: 5,

      },
    };
  },
  methods: {
    //当每页显示条数改变时
    handleSizeChange(size) {
      this.query.pageSize = size;
      this.loadSystemRunning();
    },
    //当页数改变时
    handleCurrentChange(currentPage) {
      this.query.pageIndex = currentPage;
      this.loadSystemRunning();
    },
    loadSystemRunning() {
      this.$axios.post("log/queryAllSystemRunning",this.query).then((res) => {
        this.logList = res.data.data.list;
        this.pageInfo.total = res.data.data.total;
      });
    },

    handleDelete(id) {
      this.$axios
        .delete("log/deleteSR/" + id)
        .then((res) => {
          if (res.data.code == 200) {
            this.$message.success("删除成功");
            this.loadSystemRunning();
          } else {
            this.$message.info("删除失败");
          }
        })
        .catch((error) => {
          this.$message.error("出错了！请稍后重试");
        });
    },
  },
  mounted() {
    this.loadSystemRunning();
  },
};
</script>

<style scoped>
</style>
